
__all__ = ['pyLotInfoXmlHandler', 'SvnInfoXmlHandler', 'parse_xml']

import xml.sax
from _pylot.core.utils import parse_xml

class pyLotInfoXmlHandler (xml.sax.ContentHandler):
  def __init__ (self) :
    self.element = ''
    self.infos = {}

  def characters (self, content):
    if content.strip() and self.element.strip() :
      self.infos[self.element] = content

  def startElement(self, name, attrs):
    self.element = name

  def endElement(self, name):
    try : self.infos[name]
    except KeyError :
      self.infos[name] = ''

class SvnInfoXmlHandler (xml.sax.ContentHandler):
  def __init__ (self) :
    self.element = ''
    self.svn_infos = {}

  def characters (self, content):
    if content.strip() and self.element.strip() :
      self.svn_infos[self.element] = content

  def startElement(self, name, attrs):
    self.element = name
